//
//  SafeAreaTableViewCell.m
//  Leo01
//
//  Created by 张旭 on 15/9/16.
//  Copyright (c) 2015年 张旭. All rights reserved.
//

#import "SafeAreaTableViewCell.h"
#import "LeoMsg.h"

@implementation SafeAreaTableViewCell
@synthesize navController;
@synthesize nameLabel;
@synthesize detailsLabel;
@synthesize areaOnOff;
@synthesize mainImage;
@synthesize ImageMap;

-(SafeAreaTableViewCell *)getandSetData:(NSDictionary *)subdic{
    nameLabel.text = [subdic objectForKey:@"name"];
    detailsLabel.text = [NSString stringWithFormat:@"%@m,%@",[subdic objectForKey:@"radius"],[subdic objectForKey:@"position"]];
    [areaOnOff setOn:[[subdic objectForKey:@"status"]isEqualToString:@"0"]?NO:YES];
    [mainImage setImage:[UIImage imageNamed:[self getImageName:[subdic objectForKey:@"name"]]]];
    
    
    
    //**变Cell高度模块
//    float sum=80;
//    NSString *position= [NSString stringWithFormat:@"%@m,%@",[subdic objectForKey:@"radius"],[subdic objectForKey:@"position"]];
//    //***详细地址
//    if ([LeoMsg convertToInt:position]>15)
//    {
//        sum= sum+15*([LeoMsg convertToInt:position]/15);
//    }
//    //**地址名称
//    NSString *positionName= [NSString stringWithFormat:@"%@",[subdic objectForKey:@"name"]];
//    if ([LeoMsg convertToInt:position]>15)
//    {
//        sum= sum+15*([LeoMsg convertToInt:position]/15);
//    }
//    
//    if (sum>80){
//        [self setFrame:CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, sum)];
//
//    }
    
    
    return self;
}

- (NSString *)getImageName:(NSString *)name{
    switch ([ImageMap indexOfObject:name]) {
        case 0:
            return @"home";
            break;
        case 1:
            return @"school";
            break;
        default:
            //need use default img
            return @"manage_icon_3";
            break;
    }
}

- (void)awakeFromNib {
    // Initialization code
    ImageMap = [NSArray arrayWithObjects:@"家",@"学校",@"其他",nil];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
